<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
      <el-form-item label="视频ID" prop="videoId">
        <el-input
          v-model="queryParams.videoId"
          placeholder="视频ID"
          clearable
          style="width: 120px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="模型ID" prop="modelId">
        <el-input
          v-model="queryParams.modelId"
          placeholder="模型ID"
          clearable
          style="width: 120px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="批次ID" prop="detectionBatchId">
        <el-input
          v-model="queryParams.detectionBatchId"
          placeholder="检测批次ID"
          clearable
          style="width: 150px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="会话开始" prop="sessionStartTime">
        <el-date-picker
          v-model="queryParams.sessionStartTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期"
          clearable
          style="width: 140px">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="置信度等级" prop="confidenceLevel">
        <el-select
          v-model="queryParams.confidenceLevel"
          placeholder="置信度等级"
          clearable
          style="width: 120px">
          <el-option label="低" value="低"></el-option>
          <el-option label="中" value="中"></el-option>
          <el-option label="高" value="高"></el-option>
          <el-option label="极高" value="极高"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="检测质量" prop="detectionQuality">
        <el-select
          v-model="queryParams.detectionQuality"
          placeholder="检测质量"
          clearable
          style="width: 120px">
          <el-option label="一般" value="一般"></el-option>
          <el-option label="良好" value="良好"></el-option>
          <el-option label="优秀" value="优秀"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="鱼类物种" prop="species">
        <el-input
          v-model="queryParams.species"
          placeholder="鱼类物种"
          clearable
          style="width: 120px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生长阶段" prop="ageStage">
        <el-select
          v-model="queryParams.ageStage"
          placeholder="生长阶段"
          clearable
          style="width: 120px">
          <el-option label="幼鱼" value="幼鱼"></el-option>
          <el-option label="成鱼" value="成鱼"></el-option>
          <el-option label="大型成鱼" value="大型成鱼"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="健康状态" prop="healthStatus">
        <el-select
          v-model="queryParams.healthStatus"
          placeholder="健康状态"
          clearable
          style="width: 120px">
          <el-option label="健康" value="健康"></el-option>
          <el-option label="一般" value="一般"></el-option>
          <el-option label="异常" value="异常"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="活动状态" prop="activity">
        <el-select
          v-model="queryParams.activity"
          placeholder="活动状态"
          clearable
          style="width: 120px">
          <el-option label="游泳" value="游泳"></el-option>
          <el-option label="觅食" value="觅食"></el-option>
          <el-option label="休息" value="休息"></el-option>
          <el-option label="追逐" value="追逐"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:fishDetectionResult:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:fishDetectionResult:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:fishDetectionResult:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:fishDetectionResult:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table 
      v-loading="loading" 
      :data="fishDetectionResultList" 
      @selection-change="handleSelectionChange"
      stripe
      border
      highlight-current-row
      class="common-table"
      style="font-size: 13px"
    >
      <el-table-column type="selection" width="45" align="center" />
      <el-table-column label="结果ID" align="center" prop="resultId" width="80" />
      <el-table-column label="视频ID" align="center" prop="videoId" width="70" />
      <el-table-column label="模型ID" align="center" prop="modelId" width="70" />
      <el-table-column label="批次ID" align="center" prop="detectionBatchId" width="160" show-overflow-tooltip />
      <el-table-column label="帧ID" align="center" prop="frameId" width="60" />
      <el-table-column label="会话开始" align="center" prop="sessionStartTime" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.sessionStartTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="置信度" align="center" prop="confidence" width="70">
        <template slot-scope="scope">
          <span>{{ scope.row.confidence }}%</span>
        </template>
      </el-table-column>
      <el-table-column label="等级" align="center" prop="confidenceLevel" width="60">
        <template slot-scope="scope">
          <el-tag :type="scope.row.confidenceLevel === '极高' ? 'success' : scope.row.confidenceLevel === '高' ? 'primary' : scope.row.confidenceLevel === '中' ? 'warning' : 'info'" size="mini">
            {{ scope.row.confidenceLevel }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="质量" align="center" prop="detectionQuality" width="60">
        <template slot-scope="scope">
          <el-tag :type="scope.row.detectionQuality === '优秀' ? 'success' : scope.row.detectionQuality === '良好' ? 'primary' : 'warning'" size="mini">
            {{ scope.row.detectionQuality }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="位置信息" align="center" width="140">
        <template slot-scope="scope">
          <div style="font-size: 11px">
            <div>X:{{ scope.row.bboxX }},Y:{{ scope.row.bboxY }}</div>
            <div>W:{{ scope.row.bboxWidth }},H:{{ scope.row.bboxHeight }}</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="物种" align="center" prop="species" width="80" show-overflow-tooltip />
      <el-table-column label="体长(cm)" align="center" prop="estimatedLength" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row.estimatedLength ? scope.row.estimatedLength.toFixed(1) : '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="体重(g)" align="center" prop="estimatedWeight" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row.estimatedWeight ? scope.row.estimatedWeight.toFixed(1) : '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="年龄(岁)" align="center" prop="estimatedAge" width="70" />
      <el-table-column label="生长阶段" align="center" prop="ageStage" width="90">
        <template slot-scope="scope">
          <el-tag :type="scope.row.ageStage === '大型成鱼' ? 'success' : scope.row.ageStage === '成鱼' ? 'primary' : 'warning'" size="mini">
            {{ scope.row.ageStage }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="健康状态" align="center" prop="healthStatus" width="80">
        <template slot-scope="scope">
          <el-tag :type="scope.row.healthStatus === '健康' ? 'success' : scope.row.healthStatus === '一般' ? 'warning' : 'danger'" size="mini">
            {{ scope.row.healthStatus }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="活动状态" align="center" prop="activity" width="80">
        <template slot-scope="scope">
          <el-tag :type="scope.row.activity === '游泳' ? 'primary' : scope.row.activity === '觅食' ? 'success' : scope.row.activity === '追逐' ? 'warning' : 'info'" size="mini">
            {{ scope.row.activity }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="游速(m/s)" align="center" prop="estimatedSpeed" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row.estimatedSpeed ? scope.row.estimatedSpeed.toFixed(2) : '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="朝向(°)" align="center" prop="orientation" width="70">
        <template slot-scope="scope">
          <span>{{ scope.row.orientation ? scope.row.orientation.toFixed(0) : '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="方向" align="center" prop="direction" width="60">
        <template slot-scope="scope">
          <i :class="getDirectionIcon(scope.row.direction)" style="font-size: 14px; color: #409eff"></i>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="120" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:fishDetectionResult:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:fishDetectionResult:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改鱼类检测结果详情对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px" size="small">
        <el-tabs v-model="activeTab" type="border-card">
          <el-tab-pane label="基本信息" name="basic">
        <el-row :gutter="20">
              <el-col :span="8">
            <el-form-item label="视频ID" prop="videoId">
                  <el-input-number v-model="form.videoId" placeholder="视频ID" :min="1" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
              <el-col :span="8">
            <el-form-item label="模型ID" prop="modelId">
                  <el-input-number v-model="form.modelId" placeholder="模型ID" :min="1" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
              <el-col :span="8">
            <el-form-item label="视频帧ID" prop="frameId">
                  <el-input-number v-model="form.frameId" placeholder="帧ID" :min="1" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
                <el-form-item label="批次ID" prop="detectionBatchId">
                  <el-input v-model="form.detectionBatchId" placeholder="检测批次ID" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
                <el-form-item label="会话开始" prop="sessionStartTime">
                  <el-date-picker
                v-model="form.sessionStartTime"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="选择会话开始时间"
                    style="width: 100%">
              </el-date-picker>
            </el-form-item>
          </el-col>
              <el-col :span="8">
                <el-form-item label="置信度阈值" prop="confidenceThreshold">
                  <el-input-number v-model="form.confidenceThreshold" :precision="2" :min="0" :max="1" :step="0.01" controls-position="right" style="width: 100%" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
            <el-form-item label="检测置信度" prop="confidence">
                  <el-input-number v-model="form.confidence" :precision="2" :min="0" :max="100" :step="0.1" controls-position="right" style="width: 100%">
                    <template slot="append">%</template>
                  </el-input-number>
            </el-form-item>
          </el-col>
              <el-col :span="8">
                <el-form-item label="置信度等级" prop="confidenceLevel">
                  <el-select v-model="form.confidenceLevel" placeholder="选择置信度等级" style="width: 100%">
                    <el-option label="低" value="低"></el-option>
                    <el-option label="中" value="中"></el-option>
                    <el-option label="高" value="高"></el-option>
                    <el-option label="极高" value="极高"></el-option>
                  </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
                <el-form-item label="检测质量" prop="detectionQuality">
                  <el-select v-model="form.detectionQuality" placeholder="选择检测质量" style="width: 100%">
                    <el-option label="一般" value="一般"></el-option>
                    <el-option label="良好" value="良好"></el-option>
                    <el-option label="优秀" value="优秀"></el-option>
                  </el-select>
            </el-form-item>
          </el-col>
            </el-row>
          </el-tab-pane>
          
          <el-tab-pane label="位置信息" name="position">
            <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="边界框X坐标" prop="bboxX">
                  <el-input-number v-model="form.bboxX" :min="0" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="边界框Y坐标" prop="bboxY">
                  <el-input-number v-model="form.bboxY" :min="0" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="边界框宽度" prop="bboxWidth">
                  <el-input-number v-model="form.bboxWidth" :min="1" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="边界框高度" prop="bboxHeight">
                  <el-input-number v-model="form.bboxHeight" :min="1" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="中心点X坐标" prop="centerX">
                  <el-input-number v-model="form.centerX" :min="0" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="中心点Y坐标" prop="centerY">
                  <el-input-number v-model="form.centerY" :min="0" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="边界框面积" prop="bboxArea">
                  <el-input-number v-model="form.bboxArea" :min="0" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="长宽比" prop="aspectRatio">
                  <el-input-number v-model="form.aspectRatio" :precision="2" :min="0" :step="0.01" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
            </el-row>
          </el-tab-pane>
          
          <el-tab-pane label="生物特征" name="biology">
            <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="鱼类物种" prop="species">
                  <el-input v-model="form.species" placeholder="鱼类物种" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物种类别" prop="speciesCategory">
                  <el-input v-model="form.speciesCategory" placeholder="物种类别" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="体长(cm)" prop="estimatedLength">
                  <el-input-number v-model="form.estimatedLength" :precision="2" :min="0" :step="0.1" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
              <el-col :span="8">
                <el-form-item label="体高(cm)" prop="estimatedHeight">
                  <el-input-number v-model="form.estimatedHeight" :precision="2" :min="0" :step="0.1" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
              <el-col :span="8">
                <el-form-item label="体重(g)" prop="estimatedWeight">
                  <el-input-number v-model="form.estimatedWeight" :precision="2" :min="0" :step="0.1" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
              <el-col :span="8">
                <el-form-item label="估算年龄(岁)" prop="estimatedAge">
                  <el-input-number v-model="form.estimatedAge" :min="0" :max="50" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
              <el-col :span="8">
                <el-form-item label="生长阶段" prop="ageStage">
                  <el-select v-model="form.ageStage" placeholder="选择生长阶段" style="width: 100%">
                    <el-option label="幼鱼" value="幼鱼"></el-option>
                    <el-option label="成鱼" value="成鱼"></el-option>
                    <el-option label="大型成鱼" value="大型成鱼"></el-option>
                  </el-select>
            </el-form-item>
          </el-col>
              <el-col :span="8">
                <el-form-item label="健康状态" prop="healthStatus">
                  <el-select v-model="form.healthStatus" placeholder="选择健康状态" style="width: 100%">
                    <el-option label="健康" value="健康"></el-option>
                    <el-option label="一般" value="一般"></el-option>
                    <el-option label="异常" value="异常"></el-option>
                  </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
                <el-form-item label="体况系数" prop="conditionFactor">
                  <el-input-number v-model="form.conditionFactor" :precision="2" :min="0" :step="0.01" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
                <el-form-item label="尺寸置信度" prop="sizeConfidence">
                  <el-input v-model="form.sizeConfidence" placeholder="尺寸检测置信度" />
            </el-form-item>
          </el-col>
            </el-row>
          </el-tab-pane>
          
          <el-tab-pane label="行为信息" name="behavior">
            <el-row :gutter="20">
          <el-col :span="12">
                <el-form-item label="活动状态" prop="activity">
                  <el-select v-model="form.activity" placeholder="选择活动状态" style="width: 100%">
                    <el-option label="游泳" value="游泳"></el-option>
                    <el-option label="觅食" value="觅食"></el-option>
                    <el-option label="休息" value="休息"></el-option>
                    <el-option label="追逐" value="追逐"></el-option>
                  </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
                <el-form-item label="游泳方向" prop="direction">
                  <el-select v-model="form.direction" placeholder="选择游泳方向" style="width: 100%">
                    <el-option label="向左" value="向左"></el-option>
                    <el-option label="向右" value="向右"></el-option>
                    <el-option label="向上" value="向上"></el-option>
                    <el-option label="向下" value="向下"></el-option>
                  </el-select>
            </el-form-item>
          </el-col>
              <el-col :span="8">
                <el-form-item label="当前游速(m/s)" prop="estimatedSpeed">
                  <el-input-number v-model="form.estimatedSpeed" :precision="2" :min="0" :step="0.01" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
              <el-col :span="8">
                <el-form-item label="最大游速(cm/s)" prop="maxSwimSpeed">
                  <el-input-number v-model="form.maxSwimSpeed" :precision="2" :min="0" :step="0.1" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
              <el-col :span="8">
                <el-form-item label="游泳朝向(度)" prop="orientation">
                  <el-input-number v-model="form.orientation" :precision="1" :min="0" :max="360" :step="1" controls-position="right" style="width: 100%" />
            </el-form-item>
          </el-col>
        </el-row>
          </el-tab-pane>
        </el-tabs>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listFishDetectionResult, getFishDetectionResult, delFishDetectionResult, addFishDetectionResult, updateFishDetectionResult } from "@/api/system/fishDetectionResult";

export default {
  name: "FishDetectionResult",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 鱼类检测结果详情表格数据
      fishDetectionResultList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 当前活跃的选项卡
      activeTab: 'basic',
      // 查询参数（简化后的搜索条件）
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        videoId: null,
        modelId: null,
        detectionBatchId: null,
        sessionStartTime: null,
        confidenceLevel: null,
        detectionQuality: null,
        species: null,
        ageStage: null,
        healthStatus: null,
        activity: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        videoId: [
          { required: true, message: "视频ID不能为空", trigger: "blur" }
        ],
        modelId: [
          { required: true, message: "模型ID不能为空", trigger: "blur" }
        ],
        detectionBatchId: [
          { required: true, message: "批次ID不能为空", trigger: "blur" }
        ],
        frameId: [
          { required: true, message: "视频帧ID不能为空", trigger: "blur" }
        ],
        detectionTime: [
          { required: true, message: "检测时间戳不能为空", trigger: "blur" }
        ],
        confidence: [
          { required: true, message: "检测置信度不能为空", trigger: "blur" },
          { type: 'number', min: 0, max: 100, message: '置信度应在0-100之间', trigger: 'blur' }
        ],
        bboxX: [
          { required: true, message: "边界框X坐标不能为空", trigger: "blur" }
        ],
        bboxY: [
          { required: true, message: "边界框Y坐标不能为空", trigger: "blur" }
        ],
        bboxWidth: [
          { required: true, message: "边界框宽度不能为空", trigger: "blur" }
        ],
        bboxHeight: [
          { required: true, message: "边界框高度不能为空", trigger: "blur" }
        ],
        confidenceThreshold: [
          { type: 'number', min: 0, max: 1, message: '置信度阈值应在0-1之间', trigger: 'blur' }
        ],
        orientation: [
          { type: 'number', min: 0, max: 360, message: '游泳朝向应在0-360度之间', trigger: 'blur' }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询鱼类检测结果详情列表 */
    getList() {
      this.loading = true;
      listFishDetectionResult(this.queryParams).then(response => {
        this.fishDetectionResultList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 根据游泳方向获取图标
    getDirectionIcon(direction) {
      const iconMap = {
        '向左': 'el-icon-back',
        '向右': 'el-icon-right',
        '向上': 'el-icon-top',
        '向下': 'el-icon-bottom'
      };
      return iconMap[direction] || 'el-icon-position';
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        resultId: null,
        videoId: null,
        modelId: null,
        detectionBatchId: null,
        frameId: null,
        detectionTime: null,
        confidenceThreshold: null,
        sessionStartTime: null,
        confidence: null,
        confidenceLevel: null,
        detectionQuality: null,
        bboxX: null,
        bboxY: null,
        bboxWidth: null,
        bboxHeight: null,
        centerX: null,
        centerY: null,
        bboxArea: null,
        aspectRatio: null,
        species: null,
        speciesCategory: null,
        estimatedLength: null,
        estimatedHeight: null,
        estimatedWeight: null,
        sizeConfidence: null,
        estimatedAge: null,
        ageStage: null,
        healthStatus: null,
        conditionFactor: null,
        activity: null,
        estimatedSpeed: null,
        maxSwimSpeed: null,
        orientation: null,
        direction: null,
        additionalInfo: null
      };
      this.resetForm("form");
      this.activeTab = 'basic'; // 重置选项卡到基本信息
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.resultId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加鱼类检测结果详情";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const resultId = row.resultId || this.ids
      getFishDetectionResult(resultId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改鱼类检测结果详情";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.resultId != null) {
            updateFishDetectionResult(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addFishDetectionResult(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const resultIds = row.resultId || this.ids;
      this.$modal.confirm('是否确认删除鱼类检测结果详情编号为"' + resultIds + '"的数据项？').then(function() {
        return delFishDetectionResult(resultIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/fishDetectionResult/export', {
        ...this.queryParams
      }, `fishDetectionResult_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>

<style scoped>
.common-table .el-table__cell {
  padding: 8px 0;
}

.el-tag {
  border-radius: 12px;
}

.el-dialog__body {
  padding: 15px 20px;
}

.el-tabs--border-card > .el-tabs__content {
  padding: 20px;
}

.el-form-item {
  margin-bottom: 18px;
}

.el-input-number {
  width: 100%;
}

.el-input-number .el-input__inner {
  text-align: left;
}

/* 表格行高度优化 */
.el-table .cell {
  line-height: 1.3;
}

/* 紧凑的数值显示 */
.el-table td {
  border-bottom: 1px solid #ebeef5;
}

/* 标签样式优化 */
.el-tag--mini {
  height: 20px;
  line-height: 18px;
  font-size: 11px;
  padding: 0 5px;
}
</style>
